package top.tagao.multithread_02_use.way;

/**
 * @author fu-xiao-liu
 * @Date 2022/3/29 20:59
 */
public class Way_02_yield {
    public static void main(String[] args) {
        Music1 music = new Music1();
        Read1 read = new Read1();

        music.setPriority(1);
        read.setPriority(10);
        read.start();
        music.start();
    }
}

class Read1 extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            if (i == 10){
                //Thread.yield();
            }
            System.out.println(i + "读书+");
        }
    }
}
class Music1 extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(i + "在听音乐------------");
        }
    }
}